from fastapi import FastAPI
from fastapi.responses import HTMLResponse

app = FastAPI()


@app.get("/")
async def main():
    html = """\
    <html><head><style> ul { font-size: 2em; } </style></head><body>
    <ul>
        <li><a href='/story/1001'>故事1</a></li>
        <li><a href='/story/1002'>故事2</a></li>
    </ul>
    </body></html>\
    """
    return HTMLResponse(content=html, status_code=200)


@app.get("/story/{story_id}")
async def get_story(story_id: int):
    html = f"""<html><body>
    <div><a href="/">返回</a></div>
    <h1>story #{story_id}</h1>
    ....
    </body></html>
    """
    return HTMLResponse(content=html, status_code=200)
